﻿using UnityEngine;

namespace Gp.Scripts.Core {
    public abstract class ModelAnimBase {
        protected UnitModel Model;
        protected Animator Animator => Model.Animator;
        protected BaseUnit UnitReference => Model.UnitReference;
        
        
        
        
        public void Init(UnitModel model) {
            Model = model;
            OnInit();
        }
        
        protected virtual void OnInit() {}
        
        
        
        
        
        /// <summary>
        /// 设置动画机层级
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="weight"></param>
        public void SetAnimatorLayerWeight(UnitAnimatorLayer layer, int weight) {
            Animator.SetLayerWeight(layer.LayerCode(), weight);
        }

        /// <summary>
        /// 设置Model当前状态
        /// </summary>
        /// <param name="status"></param>
        public void SetModelStatus(UnitModelStatus status) {
            Animator.SetInteger(UnitAnimatorParameter.StatusInt, status.StatusCode());
        }
    }
}